package edu.drexel.jrexel2d.networking.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;

import edu.drexel.jrexel2d.networking.NetworkClient;
import edu.drexel.jrexel2d.networking.Serializer;

public class NetworkClientDriver {


	public static void main(String[] args){
		
	try {
			NetworkClient client = new NetworkClient(InetAddress.getByName("localhost"), 9876, 1024);
		BufferedReader inFromUser =new BufferedReader(new InputStreamReader(System.in));
			while(true){
				client.sendSerializable(new Person(inFromUser.readLine(), inFromUser.readLine()));
				client.receivePacket();
				byte[] data =client.getData();
				System.out.println((Person)Serializer.deserializeBytes(data));
			}
		
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
/*
		try {
			NetworkClient client = new NetworkClient(InetAddress.getByName("localhost"), 9876, 1024);
			client.sendData();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
	}
}
